#include <stdio.h>
typedef struct
{
	int num;
	char name[20];
	int a;
	int b;
	int c;
    float average;
} Student ;
float average(Student* p)
{
	float average=((*p).a+(*p).b+(*p).c)/3.0;
	return average;
}
void exchange(Student *p1,Student* p2)
{
	Student temp=*p1;
	*p1=*p2;
	*p2=temp;
}
int main()
{
	int n;
	scanf("%d",&n);
	Student student[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d %s %d %d %d",&student[i].num,student[i].name,&student[i].a,&student[i].b,&student[i].c);
		student[i].average=average(&student[i]);
	}
	for(int i=0;i<n-1;i++)
	{
		for(int j=0;j<n-1-i;j++)
		{
			if(student[j].average<student[j+1].average)
			{
				exchange(&student[j],&student[j+1]);
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		printf("%d %s %.1f\n",student[i].num,student[i].name,student[i].average);
	}
	return 0;
}
